@extends('home.layout.base')
@section('content')
		<!-- login -->
		<div class="top center">
			<div class="logo center">
				<a href="/index" target="_blank"><img src="./image/mistore_logo.png" alt=""></a>
			</div>
		</div>
		<form  method="post" action="#" class="form center layui-form">
			{{ csrf_field() }}
		<div class="login">
			<div class="login_center">
				<div class="login_top">
					<div class="left fl">会员登录</div>
					<div class="right fr">您还不是我们的会员？<a href="/register" target="_self">立即注册</a></div>
					<div class="clear"></div>
					<div class="xian center"></div>
				</div>
				<div class="login_main center">
					<div class="username">用户名:&nbsp;<input class="shurukuang" type="text" lay-verify="required|email" name="email" placeholder="请输入你的用户名"/></div>
					<div class="username">密&nbsp;&nbsp;&nbsp;&nbsp;码:&nbsp;<input class="shurukuang" type="password" lay-verify="required" name="password" placeholder="请输入你的密码"/></div>
					<div class="username">
						<div class="left fl">验证码:&nbsp;<input class="yanzhengma" type="text" lay-verify="required" name="username" placeholder="请输入验证码"/></div>
						<div class="right fl"><a href="javascript:;"><img src="{{captcha_src()}}" id="captcha"></a></div>
						<div class="clear"></div>
					</div>
				</div>
				<div class="login_submit">
					<input class="submit" type="submit" name="submit" lay-submit="" lay-filter="logform" value="立即登录" >
				</div>
				
			</div>
		</div>
		</form>
	@include('home.layout.footer')
@endsection
@section('js')
	<script type="text/javascript">
        layui.use(['form','layer', 'jquery'],function () {
            var layer= layui.layer, form = layui.form, $ = layui.jquery;
            form.on('submit(logform)', function(data){
                var userinfo = data.field; //当前容器的全部表单字段，名值对形式：{name: value}
                $.post('/login',userinfo,function (res) {
                    if(res.code == 0){
                        layer.msg(res.data, function(){
                            window.location.href="/";
                        });
                    }else {
                        layer.msg(res.data);
                    }
                    return false;
                },'json');
                return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
            });
            $('#captcha').click(function () {
                $(this).attr('src', '/captcha/?' + Math.random());
            });
        });
	</script>
@endsection